

use "$data/clean/clean_main_complete.dta" , replace

********************************************************************************
********************************************************************************
********************************************************************************

 
		   
loc experiments " any_doors "

		   
		   
preserve

clear all
eststo clear
estimates drop _all

set obs 10
qui gen x = 1
qui gen y = 1

loc columns = 0

foreach choice in `experiments' `experiments'  {

    loc ++columns
    qui eststo col`columns': reg x y

}

restore


/* Statistics */

loc colnum = 1
loc colnames ""


foreach choice in `experiments' {

/* Statistics */



 
 
********************************Panel A*****************************************
	
 xi: logit `choice' 1.treat_any  , vce(r) // 
   
   
   
    sigstar 1.treat_any   , prec(3)
    estadd loc thisstat3 = "`r(bstar)'": col`colnum'
    estadd loc thisstat4 = "`r(sestar)'": col`colnum'
   
margin 1.treat_any  , post
local t= e(b)[1,1]
estadd loc thisstat6 = string(`t', "%9.3f"): col`colnum'


	
    loc ++colnum
    loc colnames "`colnames' `"`: var la `choice''"'"
	
	
 xi: logit `choice' 1.treat_any $control , vce(r) // 
   
  
  
    sigstar 1.treat_any   , prec(3)
    estadd loc thisstat3 = "`r(bstar)'": col`colnum'
    estadd loc thisstat4 = "`r(sestar)'": col`colnum'
   
    margin 1.treat_any  , post
local t= e(b)[1,1]
estadd loc thisstat6 = string(`t', "%9.3f"): col`colnum'


	
    loc ++colnum
    loc colnames "`colnames' `"`: var la `choice''"'"	
	

	}
	/* Statistics */

loc colnum = 1
loc colnames ""


foreach choice in `experiments' {

/* Statistics */



 
********************************Panel B*****************************************
	
logit `choice'   1.voice_instrumental_pooled  1.voice_intrinsic_pooled , vce(r) // 

margin 1.voice_instrumental_pooled  ,post
local t= e(b)[1,1]
estadd loc thisstat15 = string(`t', "%9.3f"): col`colnum'

 logit  `choice'  1.voice_instrumental_pooled  1.voice_intrinsic_pooled  , vce(r) // 

   
    sigstar  1.voice_instrumental_pooled   , prec(3)
    estadd loc thisstat9 = "`r(bstar)'": col`colnum'
    estadd loc thisstat10 = "`r(sestar)'": col`colnum'
   
	sigstar 1.voice_intrinsic_pooled  , prec(3)
    estadd loc thisstat12 = "`r(bstar)'": col`colnum'
    estadd loc thisstat13 = "`r(sestar)'": col`colnum'
	
	   
		test    1.voice_instrumental_pooled = 1.voice_intrinsic_pooled  
    estadd loc thisstat17 = string(`r(p)', "%9.2f"): col`colnum'

       margin 1.voice_intrinsic_pooled   ,post
local t= e(b)[1,1]
estadd loc thisstat16 = string(`t', "%9.3f"): col`colnum'	
	
   
   
	
	
    loc ++colnum
    loc colnames "`colnames' `"`: var la `choice''"'"
	
   
logit  `choice'  1.voice_instrumental_pooled  1.voice_intrinsic_pooled  $control , vce(r) // 
margin 1.voice_instrumental_pooled  ,post
local t= e(b)[1,1]
estadd loc thisstat15 = string(`t', "%9.3f"): col`colnum'

 logit  `choice'  1.voice_instrumental_pooled  1.voice_intrinsic_pooled  $control , vce(r) // 

   
    sigstar  1.voice_instrumental_pooled   , prec(3)
    estadd loc thisstat9 = "`r(bstar)'": col`colnum'
    estadd loc thisstat10 = "`r(sestar)'": col`colnum'
   
	sigstar 1.voice_intrinsic_pooled  , prec(3)
    estadd loc thisstat12 = "`r(bstar)'": col`colnum'
    estadd loc thisstat13 = "`r(sestar)'": col`colnum'
	
	   
		test    1.voice_instrumental_pooled = 1.voice_intrinsic_pooled  
    estadd loc thisstat17 = string(`r(p)', "%9.2f"): col`colnum'

       margin 1.voice_intrinsic_pooled   ,post
local t= e(b)[1,1]
estadd loc thisstat16 = string(`t', "%9.3f"): col`colnum'	

}

	
loc colnum = 1
loc colnames ""

	
foreach choice in `experiments' {
	
********************************Panel C*****************************************
	
logit `choice'   1.feedback_pooled  1.no_feedback_pooled , vce(r) // 

margin 1.feedback_pooled  ,post
local t= e(b)[1,1]
estadd loc thisstat26 = string(`t', "%9.3f"): col`colnum'

 logit  `choice'  1.feedback_pooled  1.no_feedback_pooled  , vce(r) // 

   
    sigstar  1.feedback_pooled  , prec(3)
    estadd loc thisstat20 = "`r(bstar)'": col`colnum'
    estadd loc thisstat21 = "`r(sestar)'": col`colnum'
   
	sigstar 1.no_feedback_pooled , prec(3)
    estadd loc thisstat23 = "`r(bstar)'": col`colnum'
    estadd loc thisstat24 = "`r(sestar)'": col`colnum'
	
	   
		test    1.feedback_pooled = 1.no_feedback_pooled
    estadd loc thisstat28 = string(`r(p)', "%9.2f"): col`colnum'

       margin 1.no_feedback_pooled  ,post
local t= e(b)[1,1]
estadd loc thisstat27 = string(`t', "%9.3f"): col`colnum'	
	
   
   

	
	qui sum `choice' if control==1
	estadd loc thisstat29 = string(`r(mean)', "%9.2f"): col`colnum'
	
	qui sum `choice' 
    estadd loc thisstat30 = string(`r(N)', "%9.0f"): col`colnum'
	
	
    loc ++colnum
    loc colnames "`colnames' `"`: var la `choice''"'"
	
   
logit  `choice'  1.feedback_pooled  1.no_feedback_pooled  $control , vce(r) // 
margin 1.feedback_pooled  ,post
local t= e(b)[1,1]
estadd loc thisstat26 = string(`t', "%9.3f"): col`colnum'

 logit  `choice'  1.feedback_pooled  1.no_feedback_pooled $control , vce(r) // 

   
    sigstar  1.feedback_pooled  , prec(3)
    estadd loc thisstat20 = "`r(bstar)'": col`colnum'
    estadd loc thisstat21 = "`r(sestar)'": col`colnum'
   
	sigstar 1.no_feedback_pooled , prec(3)
    estadd loc thisstat23 = "`r(bstar)'": col`colnum'
    estadd loc thisstat24 = "`r(sestar)'": col`colnum'
	
	   
		test    1.feedback_pooled = 1.no_feedback_pooled
    estadd loc thisstat28 = string(`r(p)', "%9.2f"): col`colnum'

       margin 1.no_feedback_pooled  ,post
local t= e(b)[1,1]
estadd loc thisstat27 = string(`t', "%9.3f"): col`colnum'	
	
   
   

	
	qui sum `choice' if control==1
	estadd loc thisstat29 = string(`r(mean)', "%9.2f"): col`colnum'
	
	qui sum `choice' 
    estadd loc thisstat30 = string(`r(N)', "%9.0f"): col`colnum'
	
	

	
	estadd loc thisstat31 = "X" : col`colnum'
	
	
    loc ++colnum
    loc colnames "`colnames' `"`: var la `choice''"'"	
	

	}
	


	
	
	
	 
loc rowlabels " "\textbf{Panel A: Main effects} " " " "Any voice treatment" " " " " "\hline Marginal  effect "  " \hline"  "  \textbf{Panel B: Type of voice} \\ "  " Instrumental" " " " " " Intrinsic" " " " " "\hline Marginal effect: Instrumental"  " Marginal effect: Intrinsic"    "\hline  p(Instrumental = Intrinsic)"  " \hline "  " \textbf{Panel C: Feedback announcement} \\"  "Feedback" " " " " " No feedback" " " " " "\hline Marginal effect: Instrumental"  " Marginal effect: Intrinsic"    "\hline  p(Feedback = No feedback)" "\hline Control mean" "Number of Observations" "Controls" "

loc rowstats ""

forval i = 1/31 {
    loc rowstats "`rowstats' thisstat`i'"
}



esttab col* using "$output/treat_logit.tex", replace cells(none) booktabs nonotes  compress alignment(c) nogap noobs nobaselevels label stats(`rowstats', labels(`rowlabels')) ///
 nomtitle mgroups("Any canvassing (app data)" ,  pattern(1 0 0 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))


